local skel = fk.CreateSkill{--定义
  name = "knu__ruilue",
}

Fk:loadTranslationTable{--翻译
  ["knu__ruilue"] = "睿略",
  [":knu__ruilue"] = "出牌阶段结束时，你可以视为使用【随机应变】；若造成伤害，你隐匿并结束回合。",
  ["#knu__ruilue-ask"] = "睿略：你可以视为使用【随机应变（%arg）】；若造成伤害，你隐匿并结束回合",

  ["$knu__ruilue1"] = "斩草除根，灭其退路！",
  ["$knu__ruilue2"] = "云卷云舒，处之泰然。",
}

local DIY = require "packages/diy_utility/diy_utility"


skel:addEffect(fk.EventPhaseEnd, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Play and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local name = player:getMark("adaptation-turn")
    if name == 0 then return end
    local card = Fk:cloneCard(name)
    if not card:getAvailableTargets(player) then return end
    local use = room:askToUseVirtualCard(player, {
      name = name,
      skill_name = skel.name,
      prompt = "#knu__ruilue-ask:::"..name,
      cancelable = true,
      card_filter = {
        n = 0,
      },
      skip = true,
    })
    if use then
      event:setCostData(self, {extra_data = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local use = event:getCostData(self).extra_data
    player.room:useCard(use)
    if use and use.damageDealt and not player.dead then
      DIY.enterHidden(player)
      player.room:endTurn()
    end
  end,
})

return skel